<?php

namespace Base;

use Think\Controller;

header('Content-type:text/html;charset=utf-8');

class BaseController extends Controller {

    public function _initialize() {
    	$this->back_user_id=false;
    }
    
    //判断用户是否登陆
    protected function checkLogin() {
        $this->back_user_id = session('uid') ;
        if (!$this->back_user_id) {
            $this->error('请先登陆', __APP__ . '/Admin/Admin/login');
        }
    }

    // public function customReturn($status,$content){
    //   $data['succ'] = $status;
    //   if(!$content){
    //     $content=array();
    //   }
    //   $data['data'] = $content;
    //   //$this->ajaxReturn($data);
    //   // echo (json_encode($data,JSON_UNESCAPED_SLASHES));
    //   echo str_replace("\\/", "/",  json_encode($data));
    //   exit;
    // }

      public function customReturn($status,$content){
      $data['succ'] = $status;
      if(!$content){
        $content=array();
      }
      $data['datas'] = $content;
      // dump($data);
      //$this->ajaxReturn($data);
      // echo (json_encode($data,JSON_UNESCAPED_SLASHES));
      echo str_replace("\\/", "/",  json_encode($data,JSON_UNESCAPED_UNICODE));
      exit;
    }
}
